package TestClass;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Random;

public class RelatedTermsDataGenerator {

    private static final String INSERT_SQL = "INSERT INTO related_terms (search_term, related_term, correlation_score) VALUES (?, ?, ?)";
    private static final String[] SEARCH_TERMS = {"清华大学", "计算机技术", "人工智能"};
    private static final String[] RELATED_TERMS = {"招生简章", "录取分数线", "研究生院", "考哪几门课", "哪个学校好", "最新研究方向", "课程", "未来就业前景", "项目实例"};

    public static void main(String[] args) {
        String dbUrl = "jdbc:mysql://localhost:3306/kaoyan";
        String user = "root";
        String password = "1234";

        try (Connection conn = DriverManager.getConnection(dbUrl, user, password)) {
            PreparedStatement stmt = conn.prepareStatement(INSERT_SQL);
            Random random = new Random();

            for (String searchTerm : SEARCH_TERMS) {
                for (String relatedTermSuffix : RELATED_TERMS) {
                    String relatedTerm = searchTerm + relatedTermSuffix;
                    double correlationScore = 0.5 + random.nextDouble() * 0.5;  // Generate a score between 0.5 and 1.0

                    stmt.setString(1, searchTerm);
                    stmt.setString(2, relatedTerm);
                    stmt.setDouble(3, correlationScore);

                    stmt.executeUpdate();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

